package com.shujia.flink.tf;

import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

public class Demo04Filter {
    public static void main(String[] args) throws Exception {
        /*
         * filter算子：对数据流中的数据进行过滤
         */
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        DataStreamSource<String> socketDS = env.socketTextStream("master", 8888);

        // 过滤掉偶数，保留奇数
        socketDS.filter(i->Integer.parseInt(i)%2 == 1).print();


        env.execute();
    }
}
